<template>
  <div>
    <ul>
      <li v-for="(item, index) in myarr">
        {{ item }} <button @click="btn1(index)">删除</button>
      </li>
      <button @click="btn">生成</button>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      myarr: ["1", "5", "3"],
    };
  },
  methods: {
    btn() {
      let num = parseInt(Math.random() * 20);
      this.myarr.push(num);
    },
    btn1(index) {
      this.myarr.splice(index, 1);
    },
  },
};
</script>

<style>
</style>